package com.ruoyi.ship.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ship.domain.TqwlShipLog;
import com.ruoyi.ship.service.ITqwlShipLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 查询日志Controller
 * 
 * @author ruoyi
 * @date 2021-11-05
 */
@RestController
@RequestMapping("/ship/log")
public class TqwlShipLogController extends BaseController
{
    @Autowired
    private ITqwlShipLogService tqwlShipLogService;

    /**
     * 查询查询日志列表
     */
    @PreAuthorize("@ss.hasPermi('ship:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(TqwlShipLog tqwlShipLog)
    {
        startPage();
        List<TqwlShipLog> list = tqwlShipLogService.selectTqwlShipLogList(tqwlShipLog);
        return getDataTable(list);
    }

    /**
     * 导出查询日志列表
     */
    @PreAuthorize("@ss.hasPermi('ship:log:export')")
    @Log(title = "查询日志", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TqwlShipLog tqwlShipLog)
    {
        List<TqwlShipLog> list = tqwlShipLogService.selectTqwlShipLogList(tqwlShipLog);
        ExcelUtil<TqwlShipLog> util = new ExcelUtil<TqwlShipLog>(TqwlShipLog.class);
        return util.exportExcel(list, "查询日志数据");
    }

    /**
     * 获取查询日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('ship:log:query')")
    @GetMapping(value = "/{shipLogId}")
    public AjaxResult getInfo(@PathVariable("shipLogId") Long shipLogId)
    {
        return AjaxResult.success(tqwlShipLogService.selectTqwlShipLogByShipLogId(shipLogId));
    }

    /**
     * 新增查询日志
     */
    @PreAuthorize("@ss.hasPermi('ship:log:add')")
    @Log(title = "查询日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TqwlShipLog tqwlShipLog)
    {
        return toAjax(tqwlShipLogService.insertTqwlShipLog(tqwlShipLog));
    }

    /**
     * 修改查询日志
     */
    @PreAuthorize("@ss.hasPermi('ship:log:edit')")
    @Log(title = "查询日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TqwlShipLog tqwlShipLog)
    {
        return toAjax(tqwlShipLogService.updateTqwlShipLog(tqwlShipLog));
    }

    /**
     * 删除查询日志
     */
    @PreAuthorize("@ss.hasPermi('ship:log:remove')")
    @Log(title = "查询日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{shipLogIds}")
    public AjaxResult remove(@PathVariable Long[] shipLogIds)
    {
        return toAjax(tqwlShipLogService.deleteTqwlShipLogByShipLogIds(shipLogIds));
    }
}
